﻿using DMSkin.Core.MVVM;
using System.Windows;
using System.Windows.Media;

namespace CloudMusic.Model
{
    /// <summary>
    /// 分页控件Item Model
    /// </summary>
    public class PageItemModel: ViewModelBase
    {
        private int _Type = 1;
        private Visibility _OmitVisible = Visibility.Collapsed;
        private Visibility _NumVisible = Visibility.Visible;
        private int _Page;
        private bool _IsCurrentPage;
        private SolidColorBrush _CurrentPageColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#111111"));
        /// <summary>
        /// 类型(1数字 2省略号)
        /// </summary>
        public int Type
        {
            get { return _Type; }
            set
            {
                _Type = value;
                OnPropertyChanged("Type");
                if (_Type == 1)
                {
                    NumVisible = Visibility.Visible;
                    OmitVisible = Visibility.Collapsed;
                }
                else
                {
                    NumVisible = Visibility.Collapsed;
                    OmitVisible = Visibility.Visible;
                }
            }
        }
        /// <summary>
        /// 当前页码颜色
        /// </summary>
        public SolidColorBrush CurrentPageColor
        {
            get { return _CurrentPageColor; }
            set
            {
                _CurrentPageColor = value;
                OnPropertyChanged("CurrentPageColor");
            }
        }
        /// <summary>
        /// 是否当前页码
        /// </summary>
        public bool IsCurrentPage
        {
            get { return _IsCurrentPage; }
            set
            {
                _IsCurrentPage = value;
                OnPropertyChanged("IsCurrentPage");
                if (_IsCurrentPage)
                {
                    CurrentPageColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#C62F2F"));
                }
                else
                {
                    CurrentPageColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#111111"));
                }
            }
        }
        /// <summary>
        /// 页码
        /// </summary>
        public int Page
        {
            get { return _Page; }
            set
            {
                _Page = value;
                OnPropertyChanged("Page");
            }
        }
        /// <summary>
        /// 数字可见
        /// </summary>
        public Visibility NumVisible
        {
            get { return _NumVisible; }
            set
            {
                _NumVisible = value;
                OnPropertyChanged("NumVisible");
            }
        }
        /// <summary>
        /// 省略号可见
        /// </summary>
        public Visibility OmitVisible
        {
            get { return _OmitVisible; }
            set
            {
                _OmitVisible = value;
                OnPropertyChanged("OmitVisible");
            }
        }
        /// <summary>
        /// 分页控件Item Model
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="currentPage">当前页码</param>
        /// <param name="type">类型(1数字 2省略号)</param>
        public PageItemModel(int page, int currentPage, int type = 1)
        {
            Type = type;
            Page = page;
            IsCurrentPage = page == currentPage;
        }
    }
}
